package com.ai.bitcoin.jpa.service.impl;

import com.ai.bitcoin.constant.Bcc;
import com.ai.bitcoin.jpa.dao.BccInfoEditDao;
import com.ai.bitcoin.jpa.entity.BccInfoEdit;
import com.ai.bitcoin.jpa.service.BccInfoEditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Jason
 * @date 2018/4/4
 **/
@Component
public class BccInfoEditServiceImpl implements BccInfoEditService {
    @Autowired
    BccInfoEditDao dao;

    @Override
    public List<BccInfoEdit> findByBccIdAndFieldType(String bccId, String fieldType) {
        return dao.findByBccIdAndFieldTypeAndFieldState(bccId, fieldType, Bcc.RecordState.PUBLISH);
    }

    @Override
    public List<BccInfoEdit> findByBccId(String bccId) {
        return dao.findByBccId(bccId);
    }

    @Override
    @Transactional
    public BccInfoEdit save(BccInfoEdit bccInfoEdit) {
        return dao.save(bccInfoEdit);
    }

    @Override
    public List<BccInfoEdit> findByBccIdAndFieldKey(String bccId, String fieldKey) {
        return dao.findByBccIdAndFieldKeyAndFieldState(bccId, fieldKey, Bcc.RecordState.PUBLISH);
    }

    @Override
    public List<BccInfoEdit> findByBccIdAndFieldState(String bccId, String state) {
        return dao.findByBccIdAndFieldState(bccId, state);
    }
}
